package com.company.netty;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

// @ChannelHandler.Sharable
public class ServerHandler extends SimpleChannelInboundHandler<CustomMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, CustomMessage msg) {
        System.out.println("收到消息: " + msg.getContent());
        // 模拟业务处理
        CustomMessage response = new CustomMessage(1, "Response-" + System.currentTimeMillis());
        ctx.writeAndFlush(response);
    }
}
